/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package validators;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import org.primefaces.model.DualListModel;

/**
 *
 * @author Felipe Duarte
 */
public class PickListMaterialConstruccionValidator implements Validator{

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        DualListModel dualAreas=(DualListModel)value;
        if(dualAreas.getTarget().size()<1) {
            throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error","Debe seleccionar por lo menos un material de construcción"));
        }
    }
    
}
